package com.huahua.api.entity.vo;

import com.huahua.api.entity.pojo.TtsRecord;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author Huahua-Ai
 * @date 2025-01-10 14:50:00
 * @description TTS记录视图对象
 */
public class TtsRecordVo implements Serializable {

    private Long id;
    private String textContent;
    private String status;
    private String statusDesc;
    private String fileUrl;
    private String prompt;
    private BigDecimal temperature;
    private BigDecimal topP;
    private Integer topK;
    private Integer refineMaxNewToken;
    private Integer inferMaxNewToken;
    private Boolean skipRefine;
    private String customVoice;
    private LocalDateTime createdTime;
    private LocalDateTime processStartTime;
    private LocalDateTime completedTime;
    private Long taskDurationWithWait;
    private Long taskDurationWithoutWait;
    private Integer duration;
    private String errorMessage;

    public static TtsRecordVo from(TtsRecord record) {
        if (record == null) {
            return null;
        }
        TtsRecordVo vo = new TtsRecordVo();
        vo.setId(record.getId());
        vo.setTextContent(record.getTextContent());
        vo.setStatus(record.getStatus());
        vo.setStatusDesc(getStatusDesc(record.getStatus()));
        vo.setFileUrl(record.getFileUrl());
        vo.setPrompt(record.getPrompt());
        vo.setTemperature(record.getTemperature());
        vo.setTopP(record.getTopP());
        vo.setTopK(record.getTopK());
        vo.setRefineMaxNewToken(record.getRefineMaxNewToken());
        vo.setInferMaxNewToken(record.getInferMaxNewToken());
        vo.setSkipRefine(record.getSkipRefine());
        vo.setCustomVoice(record.getCustomVoice());
        vo.setCreatedTime(record.getCreatedTime());
        vo.setProcessStartTime(record.getProcessStartTime());
        vo.setCompletedTime(record.getCompletedTime());
        vo.setTaskDurationWithWait(record.getTaskDurationWithWait());
        vo.setTaskDurationWithoutWait(record.getTaskDurationWithoutWait());
        vo.setDuration(record.getDuration());
        vo.setErrorMessage(record.getErrorMessage());
        return vo;
    }

    private static String getStatusDesc(String status) {
        switch (status) {
            case "PENDING":
                return "待开始";
            case "PROCESSING":
                return "执行中";
            case "COMPLETED":
                return "已完成";
            case "FAILED":
                return "失败";
            default:
                return status;
        }
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTextContent() {
        return textContent;
    }

    public void setTextContent(String textContent) {
        this.textContent = textContent;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getStatusDesc() {
        return statusDesc;
    }

    public void setStatusDesc(String statusDesc) {
        this.statusDesc = statusDesc;
    }

    public String getFileUrl() {
        return fileUrl;
    }

    public void setFileUrl(String fileUrl) {
        this.fileUrl = fileUrl;
    }

    public String getPrompt() {
        return prompt;
    }

    public void setPrompt(String prompt) {
        this.prompt = prompt;
    }

    public BigDecimal getTemperature() {
        return temperature;
    }

    public void setTemperature(BigDecimal temperature) {
        this.temperature = temperature;
    }

    public BigDecimal getTopP() {
        return topP;
    }

    public void setTopP(BigDecimal topP) {
        this.topP = topP;
    }

    public Integer getTopK() {
        return topK;
    }

    public void setTopK(Integer topK) {
        this.topK = topK;
    }

    public Integer getRefineMaxNewToken() {
        return refineMaxNewToken;
    }

    public void setRefineMaxNewToken(Integer refineMaxNewToken) {
        this.refineMaxNewToken = refineMaxNewToken;
    }

    public Integer getInferMaxNewToken() {
        return inferMaxNewToken;
    }

    public void setInferMaxNewToken(Integer inferMaxNewToken) {
        this.inferMaxNewToken = inferMaxNewToken;
    }

    public Boolean getSkipRefine() {
        return skipRefine;
    }

    public void setSkipRefine(Boolean skipRefine) {
        this.skipRefine = skipRefine;
    }

    public String getCustomVoice() {
        return customVoice;
    }

    public void setCustomVoice(String customVoice) {
        this.customVoice = customVoice;
    }

    public LocalDateTime getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(LocalDateTime createdTime) {
        this.createdTime = createdTime;
    }

    public LocalDateTime getProcessStartTime() {
        return processStartTime;
    }

    public void setProcessStartTime(LocalDateTime processStartTime) {
        this.processStartTime = processStartTime;
    }

    public LocalDateTime getCompletedTime() {
        return completedTime;
    }

    public void setCompletedTime(LocalDateTime completedTime) {
        this.completedTime = completedTime;
    }

    public Long getTaskDurationWithWait() {
        return taskDurationWithWait;
    }

    public void setTaskDurationWithWait(Long taskDurationWithWait) {
        this.taskDurationWithWait = taskDurationWithWait;
    }

    public Long getTaskDurationWithoutWait() {
        return taskDurationWithoutWait;
    }

    public void setTaskDurationWithoutWait(Long taskDurationWithoutWait) {
        this.taskDurationWithoutWait = taskDurationWithoutWait;
    }

    public Integer getDuration() {
        return duration;
    }

    public void setDuration(Integer duration) {
        this.duration = duration;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }
}
